//卡劵管理-充值列表-配置文件
App.util.ns('Admin.Card.Recharge');
Admin.Card.Recharge.Conf = {
    columns: [
        {name: '内容', value: 'content'},
        {name: '名称', width: '100px', value: 'name'},
        {name: '用户', width: '150px',value: function(item){
            return item.user ? item.user.nickname : '-- --';
        }},
        {name: '卡劵', width: '150px',value: function(item){
            return item.card ? item.card.name : '-- --';
        }},
        {name: '金额', width: '80px', value: 'fee'},
        {name: '是否充值', width: '80px', value: function(item){
            switch (item.status+'') {
                case '1':
                    return '未充值';
                case '2':
                    return '已充值';
            }
        }},
        {name: '创建日期', width: '80px', value: function(item){
            return App.util.formator.date(item.created_at);
        }}
    ],
    form: [
        {type: 'hidden', name: 'id'},
        {type: 'input', name: 'name', title: '名称', rule: {
            type: 'str',
            range: [0, 50]
        }},
        {type: 'selectLists', name: 'user_id', title: '用户',
            data_id: 'id',
            data_name: function(item){
                return item.id+':'+item.nickname;
            },
            dataTable: {
                baseUrl: '/admin/user/user',
                dataUrl: 'lists?status=1',
                data_id: 'id',
                data_name: 'name',
                table: {
                    id: 'id',
                    main: 0,
                    columns: [
                        {name: '用户名', value: 'nickname'}
                    ]
                },
                filter: [
                    {type: 'keywords'},
                ],
                height: '500px'
            }
        },
        {type: 'chosen', name: 'card_id', title: '卡劵',
            items: App.models.get('card-all'),
            item_key: 'id',
            item_name: 'name',
            rule: {
                type: 'num',
                range: [0, 250]
            },
            // onChange:function(self){
            //     var card = App.models.get('card-all');
            //     var card_index = [];
            //     for (var i=0;i<card.data.length;i++){
            //         var cards = card.data[i];
            //         if(cards.id == self.value()&&cards.id!=1){
            //             card_index.push([cards.id,cards.fee]);
            //         }
            //         console.log(card_index);
            //
            //     }
            //     self.form.formItems['fee'].config.items = card_index;
            //     self.form.formItems['fee'].flush();
            //     console.log(self)
            // }
        },
        {type: 'input', name: 'fee', title: '金额',
            rule: {
                type: 'str',
                range: [0, 50]
        }},
        {type: 'textarea', name: 'content', title: '内容',maxLength: 100, rule: {
            type: 'str',
            range: [0, 100]
        }}
    ]
};